<style scoped>
	/* 视图盒子 */
	.view-box{position: fixed; width: 100%; height: 100%; top: 0px; left: 0px; z-index: 1000; }
	/* EAEFF3 */
	.bg-1{height: 50%; background: linear-gradient(to bottom right, #0466c5, #3496F5);}
	.bg-2{height: 50%; background-color: #EAEFF3;}
	
	.login-box{width: 400px; height: 400px; position: absolute; left: calc(50% - 200px); top: calc(50% - 250px); }
	/* .login-box{} */
	
	
	/* logo */
	.login-top{margin-bottom: 40px; text-align: center; }
	.logo-img{width: 50px; height: 50px; vertical-align: middle;border-radius: 50%; margin-left: -10px; margin-right: 20px;}
	.logo-img{ position: relative; top: -5px; }
	.admin-title{font-size: 28px; color: #FFF; font-weight: 700;}
	
	/* 表单 */
	.from-box{padding: 20px 50px; background-color: #FFF;}
	.from-box{ border-radius: 1px; box-shadow: 1px 1px 2px #666;}
	.from-title{margin-top: 20px; margin-bottom: 30px; text-align: center;}
	
</style>
<template>
	<div class="view-box" v-if="isShow">
		<div class="bg-1"></div>
		<div class="bg-2"></div>
		<div class="login-box">
			<div class="login-box-2">
				<div class="login-top">
					<!-- <img src="./../index/admin-logo.png" class="logo-img"> -->
					<!-- <span class="admin-title">SA-后台模板</span> -->
				</div>
				<div class="from-box">
					<h3 class="from-title">注册账号</h3>
                
					<el-form size="small" label-position="left" label-width="0px">
						
						<el-form-item label="昵称：" label-width="70px">
							<el-input prefix-icon="el-icon-user"  show-word-limit v-model="m.uname" placeholder="请输入账号"></el-input>
						</el-form-item>
						<el-form-item label="账号：" label-width="70px">
							<el-input prefix-icon="el-icon-user"   show-word-limit v-model="m.uaccount" placeholder="请输入账号"></el-input>
						</el-form-item>
						<el-form-item label="密码：" label-width="70px" >
							<el-input prefix-icon="el-icon-unlock"   show-word-limit v-model="m.upwd" type="password" placeholder="请输入密码" @keyup.native.enter="ok()"></el-input>
						</el-form-item>
						<el-form-item label="手机号：" label-width="70px">
							<el-input prefix-icon="el-icon-unlock" v-model="m.uphone"    type="number" placeholder="请输入手机号" @keyup.native.enter="ok()"></el-input>
						</el-form-item>


                       <el-form-item label="性别：" label-width="70px">
							<el-radio-group v-model="m.ugender">
								<el-radio :label="1" >男</el-radio>
						<el-radio :label="2">女</el-radio>
							</el-radio-group>
						</el-form-item>

				

						<el-form-item style="margin-left: 70px">
							<el-button type="primary" @click="ok()">注册</el-button>
<!--							<el-button type="reSet">取消</el-button>-->
							<el-button type="primary" @click="openLogin()">登录</el-button>
						</el-form-item>


						
						
					</el-form>
				</div>
			</div>
		</div>
		<!-- 底部 版权 -->
		<div style="position: absolute; bottom: 20px; width: 100%; text-align: center; color: #666;">
			Copyright ©2020 sa-admin模板 | xx省xxx网络科技有限公司 - 提供技术支持
		</div>
	</div>
</template>

<script>
	export default {
		name: 'doRegister',
		data() {
			return {
				isShow: false,	// 是否显示当前视图 
				m: {
					uname: '',
					upwd: '',
                    uaccount:'',
					uphone:'',
					ugender: 1
				}
                // m:null
			}
		},
		methods: {
      
			// 点击确定 
			ok() {
				// 表单验证  
				if(this.m.uname == ''  ) {
					return this.sa.error2('请输入昵称');
				}
				if(this.m.uaccount=='' ) {
					return this.sa.error2('请输入账号');
				}
				if( this.m.upwd == '' ) {
					return this.sa.error2('请输入密码');
				}
				if( this.m.uphone == '' ) {
					return this.sa.error2('请输入手机号');
				}
                
               
                // let reg=/^[a-zA-Z0-9_-]{4,16}$/;
                // if(!reg.test(this.m.uname)){
                //     return this.sa.error2('昵称：4到16位（字母，数字，下划线，减号）');
				// }
                
				// let reg1= /^[a-zA-Z0-9_-]{4,16}$/;
                // if(!reg1.test(this.m.uaccount)){
                //     return this.sa.error2('账号：4到16位（字母，数字，下划线，减号）');
				// }

				// let reg2=/^(?![\\d]+$)(?![a-zA-Z]+$)(?![^\\da-zA-Z]+$)([^\u4e00-\u9fa5\\s]){6,20}$/;
                // if(!reg2.test(this.m.upwd)){
                //     return this.sa.error2('密码：6-20位英文字母、数字或者符号（除空格），且字母、数字和标点符号至少包含两种!');
				// }

                //  let reg3= /^1(3[0-9]|5[189]|8[6789])[0-9]{8}$/; 
                // if(!reg3.test(this.m.uphone)){
                //      return this.sa.error2('手机号格式错误');
				// }


			
				// this.sa.ajax2('/acc/doRegister', this.m, function() {
				// 	this.sa.ok2('注册成功，欢迎你：' + this.m.uname);
				// 	setTimeout(function() {
				// 		this.isShow = false;
				// 	}.bind(this), 800);
				// }.bind(this))
				this.sa.ajax(
					'/e-user/user/registered',
				{'uname' : this.m.uname, 'uaccount' : this.m.uaccount,'upwd':this.m.upwd,'ugender':this.m.ugender,'uphone':this.m.uphone},
				function(){
					this.sa.ok('注册成功');
					this.openLogin();	
					// this.$refs['sa-login'].isShow = true;
					}.bind(this),
					{type:'get'},
					
					
					);

			},
			openLogin(){
                //  this.$refs['sa-login'].isShow = true;
				// alert("123");
				this.sa_admin.closeRegister();	
				this.sa_admin.openLogin();
			}



		}
	}
</script>